package springapp.entity;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import springapp.util.Utils;

@Entity
@Table(name = "Review")
public class ReviewEntity extends CloneableEntity {

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id")
	private Integer id;

	@ManyToOne(cascade = CascadeType.ALL,fetch=FetchType.LAZY)
	@JoinColumn(name="company_id")
	private CompanyEntity companyEntity;


	@Column(name = "review")
	private String review;

	@Column(name = "rating")
	private Integer rating;

	@Column(name = "gender")
	private String gender;

	@Column(name = "experience")
	private Integer experience;

	@Column(name = "location_id")
	private Integer locationId;

	@Column(name = "designation_id")
	private Integer designationId;
	
	@Transient
	private String designationName;
	
	@Column(name = "job_type")
	private String jobType;
	
	@Transient
	private String locationName;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getReview() {
		return review;
	}

	public void setReview(String review) {
		this.review = review;
	}

	public Integer getRating() {
		return rating;
	}

	public void setRating(Integer rating) {
		this.rating = rating;
	}

	public ReviewEntity() {
	}

	public ReviewEntity(String review, Integer rating,
			String gender, Integer experience, Integer locationId,
			Integer designationId, String jobType) {
		this.review = review;
		this.rating = rating;
		this.gender = gender;
		this.experience = experience;
		this.locationId = locationId;
		this.designationId = designationId;
		this.jobType = jobType;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append(" Review Id ").append(this.id);
		builder.append(" review ").append(this.review);
		builder.append(" rating ").append(this.rating);
		return builder.toString();
	}

	@Override
	public boolean equals(Object object) {
		if (object == this) {
			return true;
		}

		if (object != null && object instanceof ReviewEntity) {
			ReviewEntity entity = (ReviewEntity) object;
			if (Utils.isEqual(entity.getId(), this.id)) {
				return true;
			}
		}

		return false;
	}

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	public Integer getExperience() {
		return experience;
	}

	public void setExperience(Integer experience) {
		this.experience = experience;
	}

	public Integer getLocationId() {
		return locationId;
	}

	public void setLocationId(Integer locationId) {
		this.locationId = locationId;
	}

	public Integer getDesignationId() {
		return designationId;
	}

	public void setDesignationId(Integer designationId) {
		this.designationId = designationId;
	}

	public String getJobType() {
		return jobType;
	}

	public void setJobType(String jobType) {
		this.jobType = jobType;
	}
	
	public String getLocationName() {
		return locationName;
	}
	
	public void setLocationName(String locationName) {
		this.locationName = locationName;
	}
	
	public String getDesignationName() {
		return designationName;
	}
	
	public void setDesignationName(String designationName) {
		this.designationName = designationName;
	}
	
	public CompanyEntity getCompanyEntity() {
		return companyEntity;
	}
	
	public void setCompanyEntity(CompanyEntity companyEntity) {
		this.companyEntity = companyEntity;
	}
}
